/*
* 等级怪物
*/
class LevelEnemy {
    public enemys: Array<Enemy> = [];//怪物集合
    private dt: number;
    constructor(level: number) {
        this.enemys = [];
        this.dt = 0;
        //console.log('###############0');
        //console.log(level);
        let gameLevel = tb_game.level[level];
        //console.log('###############1');
        //console.log(gameLevel);
        if (gameLevel) {
            for (let k in gameLevel) {
                let e = gameLevel[k];
                console.log(e);
                if (e) {
                    let tb = tb_game.enemy[e.enemy];
                    if (tb.ai == Define.Enemy_Ai_Nomeral) {
                        let enemy = new Enemy(e.enemy, e.time);
                        this.enemys.push(enemy);
                    }
                }
            }
            //console.log('###############2');
            //console.log(this.enemys);
        }

    }
    /**
    * 刷新怪物
    */
    public flushEnemy(): void {
        this.dt += Define.UpdateTime;
        //刷新怪物
        // console.log('###############');
        // console.log(this.enemys);
        for (let i = this.enemys.length-1; i >= 0; i--) {
            let enemy = this.enemys[i];
            if (enemy.time <= this.dt) {
                var index = this.enemys.indexOf(enemy);
                //  console.log('index = '+index);
                if (index > -1) {
                    this.enemys.splice(index, 1);
                    enemy.createEnemy();
                    game.enemys.push(enemy);
                }
            }
        }
        // console.log('###############');
        // console.log(this.enemys);
    }
}